from datetime import datetime, timedelta

from .Flight import Flight
from .Staff import Staff
from .Vehicle import Vehicle
from .Guarantee import Guarantee
from .Position import Position


class DispatchTask:
    def __init__(self,
            id: int,
            flight: Flight,
            guarantee_item: Guarantee,
            planned_start_time: datetime,
            planned_end_time: datetime,
            start_pos: Position,
            end_pos: Position,
            duration: timedelta,
            number: int = 0,
            weight: int = 0,    # 任务量（旅客人数）
            ):
        self._id = id
        self._flight = flight
        self._guarantee_item = guarantee_item
        self._planned_start_time = planned_start_time
        self._planned_end_time = planned_end_time
        self._number = number
        self._start_pos = start_pos
        self._end_pos = end_pos
        self._duration = duration
        self._weight = weight

    @property
    def id(self):
        return self._id

    @property
    def flight(self):
        return self._flight
    
    @property
    def guarantee_item(self):
        return self._guarantee_item
    
    @property
    def planned_start_time(self):
        return self._planned_start_time
    
    @property
    def planned_end_time(self):
        return self._planned_end_time
    
    @property
    def start_pos(self):
        return self._start_pos

    @property
    def end_pos(self):
        return self._end_pos

    @property
    def duration(self):
        return self._duration

    @property
    def weight(self):
        return self._weight


class DispatchTaskResult:
    def __init__(self,
            id: int,
            flight: Flight,         # 航班
            guarantee_item: Guarantee,     # 保障环节
            staff: Staff,           # 执行任务的员工
            vehicle: Vehicle,       # 执行任务的车辆
            start_time: datetime,   # 任务起始时间
            ready_time: datetime,   # 就位时间
            end_time: datetime,     # 任务结束时间
            ):
        self._id = id
        self._flight = flight
        self._guarantee_item = guarantee_item
        self._staff = staff
        self._vehicle = vehicle
        self._start_time = start_time
        self._ready_time = ready_time
        self._end_time = end_time


class DispatchResponse:
    def __init__(self,
            request_time: datetime,     # 请求时间
            response_time: datetime,    # 返回时间
            tasks ):                    # 派工列表
        self._request_time = request_time
        self._response_time = response_time
        self._tasks = tasks